CROSS_COMPILE ?= aarch64-nuvoton-linux-gnu-
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
CFLAGS := -Wall -g -I. -pthread  # 编译和链接阶段均支持 pthread
LDFLAGS := -pthread
OBJS := main.o serial.o tcp_server.o soft_dog.o
TARGET := testapp

.PHONY: all clean

all: $(TARGET)  # 仅在编译成功后删除 .o 文件
	@$(RM) $(OBJS)

$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) $^ -o $@

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	$(RM) $(OBJS) $(TARGET)